package com.campus.web.controller.management;


import com.campus.app.service.CheckHealthsService;

import com.campus.commons.entity.CheckHealth;
import com.campus.commons.entity.CheckMorningExercise;
import com.campus.commons.utils.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 卫生检查表 前端控制器
 * </p>
 *
 * @author Rin
 * @since 2020-12-24
 */
@RestController
@RequestMapping("/checkHealth")
public class CheckHealthController {

    @Autowired
    private CheckHealthsService checkHealthsService;

    /**
     * 查询所有分页
     * @return
     */
    @RequestMapping("/all")
    public Result<List<CheckHealth>> getAll(int page, int limit) {
        Result<List<CheckHealth>> checkHealth = checkHealthsService.getCheckHealth(page, limit);
        return checkHealth;
    }

    /**
     * 复合查询
     * @param start
     * @param end
     * @param page
     * @param limit
     * @param className
     * @param isRed
     * @return
     */
    @RequestMapping("/allDate")
    public Result<List<CheckHealth>> getAllByDate(String start, String end, int page, int limit, String className,String classRoomName ,int isRed,int isTop) {
        Result<List<CheckHealth>> checkHealthByDate = checkHealthsService.getCheckHealthByDate(start, end, page, limit, className, classRoomName, isRed, isTop);
        return checkHealthByDate;
    }
    /**
     * 删除一条查班记录
     * @param id
     * @return
     */
    @PostMapping("/delete")
    Result Delete(Integer id) {

        return checkHealthsService.del(id);
    }
    
    /**
     * 修改方法
     * @param checkHealth
     * @return
     */
    @PostMapping("/update")
    Result Update(CheckHealth checkHealth) {
        return checkHealthsService.upDate(checkHealth);
    }

    /**
     * 查询标红的班级
     * @param isRed
     * @return
     */
    @RequestMapping("/isRed")
    Result<List<CheckHealth>> getIsRed(int isRed,int page,int limit) {
        return checkHealthsService.getRedByIsRed(isRed, page, limit);
    }


    //<editor-fold desc="操作缓存">
    @ApiOperation("添加查卫生缓存信息")
    @PostMapping("/addCache")
    public Result addCacheMap(CheckHealth checkMorningExercise) {
        return checkHealthsService.addCheckClassMap(checkMorningExercise);
    }
    @ApiOperation("删除查卫生缓存")
    @PostMapping("/delCache")
    public Result deleteCacheMap(String classroomName) {
        return checkHealthsService.delCheckClassMap(classroomName);
    }
    @ApiOperation("更新查卫生缓存")
    @PostMapping("/upCache")
    public Result updateCacheMap(CheckHealth checkMorningExercise) {
        return checkHealthsService.upCheckClassMap(checkMorningExercise);

    }
    @ApiOperation("获取查卫生缓存")
    @PostMapping("/getCache")
    public Result getCacheMap() {
        return checkHealthsService.getCheckClassMap();
    }
    //</editor-fold>
}

